<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计算器</title>
</head>

<body>
    <div id="app">
        <input type="text" v-model='num1'>
        <select name="" id="" v-model='opt'>
            <option value="+">+</option>
            <option value="-">-</option>
            <option value="*">*</option>
            <option value="/">/</option>
        </select>
        <input type="text" v-model='num2'>
        <button @click='equal'>=</button>
        <input type="text" v-model='result'>
    </div>
</body>
<script src="../js/vue.js"></script>
<script>
    let app = new Vue({
        el: '#app',
        data: {
            num1: 0,
            num2: 0,
            opt: '-',
            result: 0
        },
        methods: {
            equal() {
                let optStr = 'parseInt(this.num1)' + this.opt + 'parseInt(this.num2)';
                this.result = eval(optStr)
            }
        }
    })
</script>

</html>